As an encoding method in lossless compression of a data series, a method as described below is used.
First, a predicted value is obtained for encoding target data (generation of a predicted value). Next, a residual between the predicted value and the encoding target data is obtained (generation of a residual). Then, a data series composed of the residual is encoded using an appropriate scheme to obtain encoded data (encoding of the residual).
When variable-length encoding, such as gamma encoding, is used in the encoding of the residual, it is often the case that by using an intermediate step of obtaining a residual, encoded data composed of a smaller value (a value close to 0) compared to encoding target data can be obtained and a compression effect is thus enhanced through variable-length encoding.
However, if a residual is obtained for floating-point data (encoding target data) by simple floating-point calculations, an error is generated due to a loss of information. For this reason, lossless compression cannot be performed.
To avoid a loss of information, it is possible to obtain a residual by simple integer calculations by regarding floating-point data as integer data. However, this method ignores the data structure of floating-point data, so that an appropriate residual may not be obtained.
To solve such a problem, Patent Literature 1 discloses a method in which floating-point data (a sign part, an exponent part, and a mantissa part) is separated into a first portion composed of the exponent part and a second portion composed of the sign part and the mantissa part, and a residual is obtained by regarding each portion as integer data.
A method for obtaining a residual by regarding the sign part, the exponent part, and the mantissa part as separate integer data as described above is also disclosed in other literature (for example, Patent Literature 2) and can be said to be widely used.
However, if a value of the exponent part of encoding target data is different from a value of the exponent part of a predicted value, a value represented by the mantissa part of the encoding target data and a value represented by the mantissa part of the predicted value have different numbers of digits. For this reason, if a residual between the mantissa parts is obtained by the method disclosed in Patent Literature 1 or the like, a meaningful value cannot be obtained as the residual between the mantissa parts. This may cause a reduced compression rate.
For example, assume that the encoding target data is “1.23×10^4” (the mantissa part is “1.23” and the exponent part is “4”) and that the predicted value is “9.98×10^3” (the mantissa part is “9.98” and the exponent part is “3”).
In this case, the ones place value “1” of the mantissa part “1.23” of the encoding target data denotes the ten-thousands place value “10000” in decimal notation. The ones place value “9” of the mantissa part “9.98” of the predicted value denotes the thousands place value “9000” in decimal notation.
That is, the mantissa value “1.23” of the encoding target data and the mantissa value “9.98” of the predicted value have different numbers of digits. Thus, comparison of these mantissa parts has no meaning in floating-point terms, and no meaningful value can be obtained as a residual between these mantissa parts by comparing the mantissa parts.